#!/bin/sh
#
# save -- save a running lab container to image
#
# Copyright (C) 2016-2021 Wu Zhangjin <falcon@ruma.tech>
#

TOP_DIR="$(cd "$(dirname "$0")"/../../ && pwd)"
. "$TOP_DIR"/tools/docker/config >/dev/null

[ -z "$TAG" ] && TAG=local-$(date +"%Y%m%d%H%M%S")

IMAGE=`get_lab_user`/$CURRENT:$TAG

do_op "docker commit" CONTAINER_NAME "$IMAGE"

do_unlock
set_var IMAGE
do_lock

info_print "new image name saved to $IMAGE"
